using Oracle.ManagedDataAccess.Types;

namespace OracleInternal.BinXml
{
	internal class ObxmlContentObject
	{
		private InputOutputTypes inputContentType = InputOutputTypes.None;

		internal const int s_InputNumericValueNotSet = -1;

		internal long ReadOffset
		{
			get;
			set;
		}

		internal long InputLength
		{
			get;
			set;
		}

		internal InputOutputTypes InputType
		{
			get
			{
				return inputContentType;
			}
			set
			{
				if (IsInputContentTypeValid(value))
				{
					inputContentType = value;
				}
			}
		}

		internal string StreamId
		{
			get;
			set;
		}

		internal object ContentObject
		{
			get;
			set;
		}

		internal ObxmlDecodeRequest Parent
		{
			get;
			set;
		}

		internal ObxmlContentObject(ObxmlDecodeRequest parent)
		{
			Parent = parent;
			ResetContentObject();
		}

		internal void SetObxmlContentObject(OracleBlob blob)
		{
			InputType = InputOutputTypes.OracleBlob;
			ContentObject = blob;
		}

		internal void SetObxmlContentObject(InputOutputTypes contentType, string urlOrPathOrId)
		{
			InputType = contentType;
			StreamId = urlOrPathOrId;
		}

		internal void SetObxmlContentObject(byte[] binArray)
		{
			InputType = InputOutputTypes.ByteArray;
			ContentObject = binArray;
		}

		internal bool IsInputContentTypeValid(InputOutputTypes contentType)
		{
			if (InputOutputTypes.OracleBlob == contentType || InputOutputTypes.ByteArray == contentType)
			{
				return true;
			}
			return false;
		}

		internal bool IsContentValid()
		{
			return InputType != InputOutputTypes.None;
		}

		internal bool ResetContentObject()
		{
			ContentObject = null;
			StreamId = null;
			InputType = InputOutputTypes.None;
			ReadOffset = -1L;
			InputLength = -1L;
			return true;
		}
	}
}
